package ru.pb.game.network.engine.client.packets.receivable;

import ru.pb.game.network.engine.client.packets.FromClientToGameServerPacket;
import ru.pb.game.network.engine.client.packets.sendable.opcode_3890_ACK;
import ru.pb.game.objects.model.players.Player;
import ru.pb.game.objects.model.room.Room;
import ru.pb.game.objects.storage.ObjectsStorage;

/**
 * @author DarkSkeleton
 *         Пакет отвечает за смену уровня сложности на ботах
 */
public class opcode_3890_REQ extends FromClientToGameServerPacket
{
	public opcode_3890_REQ()
	{}

	@Override
	public void readImpl()
	{
		// _log.info("opcode_3890_REQ, remaining: " + _buf.remaining());
		readH();
	}

	@Override
	public void runImpl()
	{
		Player p = getPlayer();
		Room r = p.getRoom();
		if(p != null && r != null)
		{
			if(r._aiLevel < 10)
				r._aiLevel += 1;

			Player member = null;
			for(int objId : r.getAllPlayers().toArray())
			{
				member = ObjectsStorage.getInstance().getPlayer(objId);
				member.sendPacket(new opcode_3890_ACK(r));
			}
		}
	}
}